<?php
class episode_language extends Model{
	public static function getTableName(){
		return 'episode-language';
	}
    
    public function getPrimaryKey(){
        return array('episode_id','language_id');
    }

	public function set($object){
		$this->language_id = !isset($object->language_id) ? '0' : $object->language_id;
		$this->title = !isset($object->title) ? '' : trim($object->title);
		$this->description = !isset($object->description) ? '' : $object->description;
		$this->description_short = !isset($object->description_short) ? '' : $object->description_short;
		$this->editor_message = !isset($object->editor_message) ? '' : $object->editor_message;
	}

	public function getLangEpisodeByID($episode_id, $lan_id)
	{
		$ret = Model::$dbo["r"]->findBySql(__class__, "select * from `".self::getTableName()."` where episode_id={$episode_id} and language_id={$lan_id}"); 
		return isset($ret[0]) ? $ret[0] : '';
	}

	/*
	 * by donald
	 */
	public function getAll($episode_id)
	{
		return self::$dbo['w']->find(__CLASS__, 'episode_id = ?', array($episode_id));
	}
}
?>
